<template>
  <div id="meeting">  
    <div  style="display:flex;align-items: center;">
            <img class="top_img" src="@/assets/images/a8.png" style="width:35px;height:35px;margin-right:10px;"/>
            <div style="line-height: 40px;font-weight:bold:">分享活动</div>
    </div> 
  <el-form ref="form"  label-width="70px">  

    <div style="display:flex;">
          <div style="flex:1;display:flex;align-items: center;">

          <div style="width:50px;text-align-last: justify;margin-top:-12px;font-size: 14px;color: #606266;margin-right:10px;">查询项</div>
            <el-form-item label="账户查询">
              <el-input v-model="form.phone" placeholder="姓名/手机号"  style="width:140px;"></el-input>
            </el-form-item>

            <div class="buttoon_box">
                <div class="buttoon_box_item"  style="margin-left:10px;background:#FFC600;color:white;" >确 定</div>
                <div class="buttoon_box_item" style="margin-left:10px;border:1px solid #D9D9D9;" >清 空</div>    
            </div>

         </div>

     </div>

     <div style="display:flex;align-items: center;">
            <div style="width:50px;text-align-last: justify;margin-top:-12px;font-size: 14px;color: #606266;margin-right:10px;">筛选项</div> 

            <el-form-item  label="兑奖时间"  >
                    <el-date-picker  type="date"   placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"  v-model="form.onedate" style="width:140px;"> 
                    </el-date-picker>
              </el-form-item>
            
            <el-form-item label="兑奖方式" style="margin-left:10px;">
                <el-select  v-model="form.select_num" placeholder="请选择" >
                    <el-option  v-for="(item,index) in select_data" :key="index" :label="item.name" :value="item.id"></el-option>
                </el-select>
            </el-form-item>
 
            <div class="buttoon_box">
                <div class="buttoon_box_item"  style="margin-left:10px;background:#FFC600;color:white;" >确 定</div>
                <div class="buttoon_box_item" style="margin-left:10px;border:1px solid #D9D9D9;" >清 空</div>    
            </div>
     </div>

    <el-row>

        <el-col :span="24" style="text-align: right;">          
           <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="mtk1_but()">
             <img class="custom_color_button1_img" src="@/assets/images/but_bg6.png" />获奖要求
            </el-button>  
           <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="mtk2_but()">
             <img class="custom_color_button1_img" src="@/assets/images/but_bg3.png" />奖品设置
            </el-button>     
        </el-col>
   
      </el-row>
  </el-form >

   <!-- 渲染数据list -->
   <sharinggift-list :datalist="datalist" @up_list_fun="list_fun"> </sharinggift-list>

      
   <div style="margin-top:20px;text-align: center;">
      <el-pagination
        background
        @current-change="handleCurrentChange"
        :page-size="10"  
        layout="prev, pager, next, jumper"
        :total="count">
      </el-pagination>
    </div>

        <!-- 获奖要求 -->
    <el-dialog title="获奖要求" :visible.sync="mtk1"  width="400px">
        <div style="width:100%;"> 

           <el-form ref="form"   label-width="70px" style="width:100%;">     
                <el-form-item label="好友权限">
                <el-select  v-model="mtk1_form.select_num_zy" placeholder="请选择"  style="width:100%;">
                    <el-option  v-for="(item,index) in select_data_zy" :key="index" :label="item.title" :value="item.maid"></el-option>
                </el-select>
            </el-form-item>

            </el-form>
            <div style="text-align: center;width:50%;margin:auto;">
                <el-button type="primary" class="custom_color_button" style="width:80%;" @click="mtk1_qr_but()">确认</el-button>
            </div>

        </div> 
    </el-dialog>

     <!-- 奖品设置 -->
    <el-dialog title="奖品设置" :visible.sync="mtk2"  width="400px">
        <div style="width:100%;"> 

           <el-form ref="form"   label-width="70px" style="width:100%;">     
               
                <el-form-item label="蜜贝">
                       <el-switch  
                            :active-value="mtk2_form.active1" 
                            :inactive-value="mtk2_form.isactive1" 
                            v-model="mtk2_form.isshow1" 
                            @change="switchchange1()"  
                            active-color="#F5CF49" 
                            inactive-color="#E5E5E5"
                            > 
                        </el-switch>
                </el-form-item>

                <el-form-item label="金蜜券">
                       <el-switch  
                            :active-value="mtk2_form.active2" 
                            :inactive-value="mtk2_form.isactive2" 
                            v-model="mtk2_form.isshow2" 
                            @change="switchchange2()"  
                            active-color="#F5CF49" 
                            inactive-color="#E5E5E5"
                            > 
                        </el-switch>
                </el-form-item>
            </el-form>
            <div style="text-align: center;width:50%;margin:auto;">
                <el-button type="primary" class="custom_color_button" style="width:80%;" @click="mtk2_qr_but()">确认</el-button>
            </div>

        </div> 
    </el-dialog>
     
  </div>
</template>

<script>
import SharinggiftList from '@/view/Activitynew/Sharinggift/SharinggiftList'
export default {
  name: 'meeting',
  data () {
    return {
        datalist:[],
        page:1,
        count:0,
        form:{
            phone:'',
            onedate:'',
            select_num:'',
        },
        select_data:[{"id":1,"name":"蜜贝"},{"id":2,"name":"金蜜券"}],  
        mtk1:false,
        mtk1_form:{
            select_num_zy:'',
            number2:'',
            number3:'',
            number4:'',
        },
        mtk2:false,
        mtk2_form:{
            active1:1, 
            isactive1:0, 
            isshow1:0,
            active2:1, 
            isactive2:0, 
            isshow2:0
        },
        select_data_zy:[],
    }
  },
 components:{
    SharinggiftList
  },
  created(){
     this.list_fun()
     this.list_zy()
     this.set_fun()
  },
  mounted (){
    
  },
  methods: { 
      list_zy(){
        this.post("/manor/manorOption", {
        }).then(res => { 
            this.select_data_zy = res.result     
            //console.log(this.select_data_zy)                  
        })
      },
      set_fun(){
        this.post("/share_activity/demand", {
        }).then(res => { 
            this.mtk1_form.select_num_zy =  res.result.share_activity_demand
          console.log(res,"ddffg")                  
        })
      },
      list_fun(){
           this.post("/share_activity/listOfWinPrize", {
              page:this.page,
              account:this.form.phone,
              onedate:this.form.onedate,
              type:this.form.select_num,
	         }).then(res => {
            this.count = res.result.count
            this.datalist = res.result.list
              
            console.log(this.datalist,"ddddsss")
          })
      },
     handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      mtk1_but(){
          this.mtk1 = true
      },
      mtk1_qr_but(){
        this.post("/share_activity/setDemand", {
                   share_activity_demand:this.mtk1_form.select_num_zy
                }).then(res => {

                    if(res.error_code == 0){
                      this.mtk1 = false
                      this.set_fun()
                     this.open1(res.result,'success')  //提示框
                    }else {
                     this.open1(res.message,'warning')
                }

         })
      },
      mtk2_but(){
          this.mtk2 = true
          this.mtk2_fun()
      },
      mtk2_fun(){
        this.post("/share_activity/onAndOff", {
         
                }).then(res => {
                  this.mtk2_form.isshow1 =   parseInt(res.result.share_activity_kmb_on_off)
                  this.mtk2_form.isshow2 =   parseInt(res.result.share_activity_gdbticket_on_off)
                  //console.log(res.result)

         })
      },
      mtk2_qr_but(){

        this.post("share_activity/setOnAndOff", {
                   share_activity_kmb_on_off:this.mtk2_form.isshow1,
                   share_activity_gdbticket_on_off:this.mtk2_form.isshow2,
                }).then(res => {

                    if(res.error_code == 0){
                      this.mtk2 = false
                      this.mtk2_fun()
                     this.open1(res.result,'success')  //提示框
                    }else {
                     this.open1(res.message,'warning')
                }

         })

      },
      switchchange1(){

      },
      switchchange2(){
          
      },
      handleCurrentChange(val) {
        this.page = val
        this.list_fun()
        console.log(`当前页: ${val}`);
      }
  }
}
</script>


<style scoped>
  .buttoon_box{
  display:flex;margin-bottom:10px;
}
.buttoon_box_item{
  height:40px;line-height:40px;width:60px;font-size:14px;text-align:center;border-radius:5px;
}
.el-input-box>>>input{
  padding: 0px 3px !important;
}
</style>
